package com.yanqu.road.server.cmd.beautyescort;

import com.yanqu.road.logic.config.GameConfig;
import com.yanqu.road.pb.beautyescort.BeautyEscortProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_BEAUTY_ESCORT_SET_EVENT_AUTO_HANDLE, desc = "设置事件是否自动处理")
public class BeautyEscortSetEventAutoHandleCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        if(player.getUserInfo().getTitleId() < GameConfig.ESCORT_AUTOMATIC_OPEN_LEVEL){
            ret = GameErrorCode.E_TITLE_LEVEL_NO_ENOUGH;
            return;
        }
        BeautyEscortProto.BeautyEscortSetEventAutoHandleReqMsg reqMsg = BeautyEscortProto.BeautyEscortSetEventAutoHandleReqMsg.parseFrom(packet.getBytes());
        player.sendPacket(Protocol.C_BEAUTY_ESCORT_SET_EVENT_AUTO_HANDLE, reqMsg.toBuilder());
    }

    @Override
    public void sendData(GamePlayer player) {
        if(ret != 0){
            BeautyEscortProto.BeautyEscortSetEventAutoHandleRespMsg.Builder respMsg = BeautyEscortProto.BeautyEscortSetEventAutoHandleRespMsg.newBuilder();
            respMsg.setRet(ret);
            player.sendPacket(Protocol.U_BEAUTY_ESCORT_SET_EVENT_AUTO_HANDLE, respMsg);
        }
    }
}
